package com.bishe.demo.modules.hotel.hotelDetail.controller;

import com.bishe.demo.modules.common.entity.ResultEntity;
import com.bishe.demo.modules.hotel.hotelDetail.entity.Detail;
import com.bishe.demo.modules.hotel.hotelDetail.serivce.DetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class DetailController {
    @Autowired
    private DetailService detailService;

    @PostMapping(value = "/detail", consumes = "application/json")
    ResultEntity<Detail> insertDetail(@RequestBody Detail detail) {
        return detailService.insertDetail(detail);
    }

    @GetMapping(value = "/hotelDetails")
    public List<Detail> getDetails() {
        return detailService.getDetails();
    }

    @GetMapping(value = "/hotelDetail/{hotelId}")
    public Detail getDetailByHotelId(@PathVariable int hotelId) {
        return detailService.getDetailByHotelId(hotelId);
    }

    @PutMapping(value = "/hotelDetail", consumes = "application/json")
    public ResultEntity<Detail> updateDetail(@RequestBody Detail detail) {
        return detailService.updateDetail(detail);
    }
}
